#!/bin/bash

# 默认情况下后端处于35802端口 前端分别处于3000 和 3001端口

# 启动脚本 
echo "Hello szutic developers!"

# 进入当前工作路径
script_path=$(dirname "$0")
cd $script_path

# 干掉已经启动的程序，防止重复启动
echo "killing programme"
pkill -cf "main.go"
pkill -cf "./build/main"
pkill -cf "exe/main"
pkill -cf "npm run dev"
pkill -cf "front_end/frontground"
pkill -cf "front_end/background"

# 等待time_wait
sleep 5

# 先启动后端程序
echo "### start back_end ###"
back_end/run.sh &

# 等待time_wait
sleep 5

# 前端部分等待浩杰修复
# 然后启动前端（前台）
script_path=$(dirname "$0")
cd $script_path
echo "### start front_end(frontground) ###"
front_end/frontground/run.sh &

# 等待time_wait
sleep 5

# 然后启动前端（后台）
script_path=$(dirname "$0")
cd $script_path
echo "### start front_end(background) ###"
front_end/frontground/run.sh &